package com.mxw.commons.context;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * @Description 非静态set方法注入静态变量
 * @Author RingKo
 * @Date 2022/8/1 16:03
 * @Version 1.0
 */
@Component
public class ApplicationContextHelper {
  private static ApplicationContext applicationContext;
  private static Environment environment;

  public static ApplicationContext getApplicationContext() {
    return applicationContext;
  }

  @Autowired
  public void setApplicationContext(ApplicationContext applicationContext) {
    ApplicationContextHelper.applicationContext = applicationContext;
  }

  public static Environment getEnvironment() {
    return environment;
  }

  @Autowired
  public void setEnvironment(Environment environment) {
    ApplicationContextHelper.environment = environment;
  }
}
